package com.dg.jwt;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

import java.text.SimpleDateFormat;

public class ParseJwtTest2 {

    public static void main(String[] args) {
        String compactJws = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4ODgiLCJzdWIiOiLlsI_nmb0iLCJpYXQiOjE1NDIxODE4NTIsImV4cCI6MTU0MjE4MTkxMn0.aDr0yOVaqkOtBDjkjGL4gksET3pZN3TwCuOONUPgw24";
        Claims claims = Jwts.parser().setSigningKey("itheima").parseClaimsJws(compactJws).getBody();
        System.out.println("id = "+claims.getId());
        System.out.println("subject = "+claims.getSubject());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("IssuedAt = "+format.format(claims.getIssuedAt()));
        System.out.println("过期时间 = "+format.format(claims.getExpiration()));
    }

}
